package com.zhilianbao.leyaogo.ui.activity.base;

import com.bql.fragmentation.anim.DefaultHorizontalAnimator;
import com.bql.fragmentation.anim.FragmentAnimator;
import com.bql.utils.EventManager;
import com.zhilianbao.leyaogo.events.LeEventCode;
import com.zhilianbao.leyaogo.events.UserEventCode;

/**
 * ClassName: BaseActivity <br>
 * Description: 基类Activity<br>
 * Author: Cyarie <br>
 * Created: 2016/7/15 15:50 <br>
 * Update Time：<br>
 * Update Description：<br>
 */
public abstract class BaseActivity extends BaseAppActivity {


    @Override
    protected void onHandleEvent(EventManager eventManager) {
        //用户异常登录
        if (eventManager.getEventCode() == UserEventCode.MSG_CODE_LOGIN_ERROR) {
            finish();
        }

        //程序发生异常
        if (eventManager.getEventCode() == -1) {
            finish();
        }

        //退出登录
        if (eventManager.getEventCode() == UserEventCode.MSG_CODE_LOGIN_OUT) {
            finish();
        }
        //退出登录
        if (eventManager.getEventCode() == UserEventCode.MSG_CODE_UPDATE_PASSWORD) {
            finish();
        }

        //退出登录
        if (eventManager.getEventCode() == UserEventCode.MSG_CODE_UPDATE_PASSWORD) {
            finish();
        }

        //不是首页 关闭视频悬浮窗 关闭相关页面
        if (!isMainActivity() && eventManager.getEventCode() == LeEventCode.MSG_CODE_LEXIU_CLOSE_VIDEO) {
            finish();
        }

    }

    /**
     * 是否是首页Activity
     *
     * @return
     */
    public boolean isMainActivity() {
        return false;
    }

    @Override
    protected boolean isBindEventBusHere() {
        return true;
    }

    @Override
    protected boolean toggleOverridePendingTransition() {
        return false;
    }

    @Override
    protected TransitionMode getOverridePendingTransitionMode() {
        return TransitionMode.LEFT;
    }

    @Override
    protected ScreenOrientationMode getScreenOrientationMode() {
        return ScreenOrientationMode.PORTRAIT;
    }

    @Override
    protected boolean isApplyStatusBarTranslucent() {
        return false;
    }

    @Override
    protected boolean isHideSmartBar() {
        return true;
    }

    @Override
    protected boolean isFullScreen() {
        return false;
    }

    @Override
    protected boolean enableChangeSKin() {
        return true;
    }

    @Override
    protected boolean isStatusDarkMode() {
        return false;
    }

    @Override
    protected FragmentAnimator onCreateFragmentAnimator() {
        return new DefaultHorizontalAnimator();
    }
}
